<?php

/******************************
Copyright (c) 2009, Avanade
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of Avanade nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
******************************/


/**
Function to create a simple web slice

Parameters:
	1. sliceName: String, a unique name for the web slice
	2. sliceTitle: String, a title to be displayed in the web slice
	3. content: String, content for the web slice to display

Returns:
	HTML markup for a web slice based on the specified parameters


**/

function createWebSlice($sliceName, $sliceTitle, $content)
{
	echo "<div class='hslice' id='";
	echo $sliceName;
	echo "'>";
	echo "<h3 class='entry-title'>";
	echo $sliceTitle;
	echo "</h3>";
	echo "<div class='entry-content'>";
	echo $content;
	echo "</div></div>";
}

// Call the function

createWebSlice("helloWorld", "Demo Web Slice", "Hello PHP Developers");

/**
Function to create a web slice with alternate content for the source

Parameters:
	1. sliceName: String, a unique name for the web slice
	2. sliceTitle: String, a title to display in the web slice content
	3. altPageUrl: String, URL of the alternate source for the web slice

Returns:
	HTML markup for a web slice whose content is from an alternate source as specified by the parameters.

**/

function createWebSliceFromAltSource($sliceName, $sliceTitle, $altPageUrl)
{
	echo "<div class='hslice' id='";
	echo $sliceName;
	echo "'>";
	echo "<h3 class='entry-title'>";
	echo $sliceTitle;
	echo "</h3>";
	echo "<a rel='feedurl' href='";
	echo $altPageUrl;
	echo "' style='display:none'></a>";
	echo "</div>";
}

// Call the function (Note that you may need to change the location of your source content if you have a different 
// filename or have stored it elsewhere on your web server.

createWebSliceFromAltSource("alternateSource", "Demo Web Slice from an alternate source", "http://webslicecontent.html#wsContent");

/**
Function to create a web slice specifying an RSS feed as the source

Parameters:
	1. sliceName: String, unique name for the web slice
	2. sliceTitle: String, a title to display in the web slice content
	3. content: String, content to display in the subscription portion of the web slice
	4. rssUrl: String, URL of the RSS feed to display as the web slice content

Returns:
	HTML markup for a web slice whose content is based on an RSS feed as specified by the parameters.
**/

function createWebSliceFromRss($sliceName, $sliceTitle, $content, $rssUrl)
{
	echo "<div class='hslice' id='";
	echo $sliceName;
	echo "'>";
	echo "<h3 class='entry-title'>";
	echo $sliceTitle;
	echo "</h3>";
	echo "<div class='entry-content'>";
	echo $content;
	echo "</div>";
	echo "<a rel='feedurl' href='";
	echo $rssUrl;
	echo "' style='display:none'></a>";
	echo "</div>";
}

// Call the function

createWebSliceFromRss("helloWorldRss", "Demo Web Slice from RSS", "xkcd Rules!!!","http://xkcd.com/rss.xml");

?>


